Public Class Gestor

    Private Shared ReadOnly instancia As New Gestor
    Private objG As Grupo


    Public Shared ReadOnly Property instanciar() As Gestor
        Get
            Return instancia
        End Get
    End Property

    Private Sub obtenerGrupo(ByVal pidG As Integer)
        Dim multiG As New MultiGrupo()
        objG = multiG.obtenerGrupo(pidG)
    End Sub

    Public Function darActividad(ByVal pidG As Integer) As Integer
        Dim multiG As New MultiGrupo()
        Return multiG.obtenerActividad(pidG)
    End Function

    Public Function obtenerElGrupoActivo(ByVal pidG As Integer) As DataTable
        Dim multiG As New MultiGrupo()
        Return multiG.obtenerGrupoActivo(pidG)
    End Function

    Public Function obtenerElGrupoInactivo(ByVal pidG As Integer) As DataTable
        Dim multiG As New MultiGrupo()
        Return multiG.obtenerGrupoInactivo(pidG)
    End Function

    Private Function obtenerCurso(ByVal pidC As Integer) As Curso
        Dim multiC As New MultiCurso()
        Return multiC.obtenerCurso(pidC)
    End Function


    Public Function mostrarEstudiantes(ByVal pidG As Integer) As DataTable
        Dim datos As New DataTable()
        Me.obtenerGrupo(pidG)
        datos = objG.obtenerEstudiantes()
        Return datos
    End Function



    Public Sub registrarEstudiante(ByVal pnombre As String, ByVal papellido As String, ByVal pcarne As String, ByVal pemail As String, ByVal pidG As Integer, ByVal ppass As String)
        Me.obtenerGrupo(pidG)
        objG.insertarEstudiante(pnombre, papellido, pcarne, pemail, ppass)
    End Sub



    Public Sub modificarEstudiante(ByVal pnombre As String, ByVal papellidos As String, ByVal pcarne As String, ByVal pemail As String, ByVal pidG As Integer, ByVal pidE As Integer, ByVal ppass As String)
        Me.obtenerGrupo(pidG)
        objG.modificarEstudiante(pnombre, papellidos, pcarne, pemail, pidE, ppass)
    End Sub


    Public Sub eliminarEstudiante(ByVal pidG As Integer, ByVal pidE As Integer)
        Me.obtenerGrupo(pidG)
        objG.eliminarEstudiante(pidE)
    End Sub


    Public Function mostrarGrupos() As DataTable
        Dim datos As New DataTable()
        Dim multiG As New MultiGrupo()
        datos = multiG.obtenerGruposActivos()
        Return datos
    End Function

    Public Function mostrarGruposInactivos() As DataTable
        Dim datos As New DataTable()
        Dim multiG As New MultiGrupo()
        datos = multiG.obtenerGruposInactivos()
        Return datos
    End Function

    Public Function mostrarCursos() As DataTable
        Dim datos As New DataTable()
        Dim multiC As New MultiCurso()
        datos = multiC.obtenerCursos()
        Return datos
    End Function

    Public Sub registrarCurso(ByVal pcod As String, ByVal pnom As String)
        Dim multiC As New MultiCurso()
        multiC.insertarCurso(pcod, pnom)
    End Sub

    Public Sub actualizarCurso(ByVal pidC As Integer, ByVal pcod As String, ByVal pnom As String)
        Dim multiC As New MultiCurso()
        multiC.actualizarCurso(pidC, pcod, pnom)
    End Sub

    Public Sub eliminarCurso(ByVal pidC As Integer)
        Dim multiC As New MultiCurso()
        multiC.eliminarCurso(pidC)
    End Sub


    Public Function registrarGrupo(ByVal pperi As String, ByVal phora As String, ByVal pasis As String, ByVal pidC As Integer) As Integer
        Dim multiG As New MultiGrupo()
        Return multiG.insertarGrupo(pperi, phora, pasis, pidC)
    End Function

    Public Sub actualizarGrupo(ByVal pperi As String, ByVal phora As String, ByVal pasis As String, ByVal pidC As Integer, ByVal pidG As Integer)
        Dim multiG As New MultiGrupo()
        multiG.actualizarGrupo(pperi, phora, pasis, pidC, pidG)
    End Sub

    Public Sub eliminarGrupo(ByVal pidC As Integer, ByVal pidG As Integer)
        Dim multiG As New MultiGrupo()
        multiG.eliminarGrupo(pidC, pidG)
    End Sub

    Public Function buscarCarneEstudiante(ByVal pcarne As String) As DataTable
        Dim dt As New DataTable
        Dim multiE As New MultiEstudiante
        dt = multiE.buscarEstudiantePorCarne(pcarne)
        Return dt
    End Function

    Public Function obtenerRubros(ByVal pidG As Integer) As DataTable
        Dim dt As New DataTable
        Me.obtenerGrupo(pidG)
        dt = objG.mostrarRubros()
        Return dt
    End Function

    Public Function mostrarLista(ByVal pidG As Integer, ByVal pidR As Integer) As DataTable
        Dim datos As New DataTable()
        Me.obtenerGrupo(pidG)
        datos = objG.obtenerLista(pidR)
        Return datos
    End Function

    Public Function mostrarListaEvaluada(ByVal pidG As Integer, ByVal pidR As Integer) As DataTable
        Dim datos As New DataTable()
        Me.obtenerGrupo(pidG)
        datos = objG.obtenerListaEvaluada(pidR)
        Return datos
    End Function

    Public Sub asignarNota(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pidR As Integer, ByVal pnota As String)
        Me.obtenerGrupo(pidG)
        objG.asignarNota(pidE, pidR, pnota)
    End Sub

    Public Sub darNota(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pidR As Integer, ByVal pnota As String)
        Me.obtenerGrupo(pidG)
        objG.darNota(pidE, pidR, pnota)
    End Sub

    Public Function mostrarDesgloseEstudiante(ByVal pidG As Integer, ByVal pidE As Integer) As DataTable
        Dim datos As New DataTable()
        Me.obtenerGrupo(pidG)
        datos = objG.mostrarDesgloseEstudiante(pidE)
        Return datos
    End Function

    Public Sub modificarNota(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pidR As Integer, ByVal pnota As String)
        Me.obtenerGrupo(pidG)
        objG.modificarNota(pidE, pidR, pnota)
    End Sub

    Public Sub eliminarNota(ByVal pidG As Integer, ByVal pidR As Integer, ByVal pidN As Integer)
        Me.obtenerGrupo(pidG)
        Me.objG.eliminarNota(pidR, pidN)
    End Sub

    Public Function mostrarPromedioEstudiante(ByVal pidG As Integer, ByVal pidE As Integer) As ArrayList
        Dim datos As New ArrayList()
        Me.obtenerGrupo(pidG)
        datos = objG.mostrarPromedioEstudiante(pidE)
        Return datos
    End Function

    Public Function mostrarEquipos(ByVal pidG As Integer) As DataTable
        Me.obtenerGrupo(pidG)
        Return objG.obtenerEquipos
    End Function

    Public Function mostrarEstudiantesSinEquipo(ByVal pidG As Integer) As DataTable
        Me.obtenerGrupo(pidG)
        Return objG.traigaEstudiantesLibre
    End Function

    Public Function mostrarEstudiantesEquipo(ByVal pidG As Integer, ByVal pidE As Integer) As DataTable
        Me.obtenerGrupo(pidG)
        Return objG.traigaEstudiantesEquipo(pidE)
    End Function

    Public Sub incluirEstudianteEquipo(ByVal pidG As Integer, ByVal pidEq As Integer, ByVal pidE As Integer)
        Me.obtenerGrupo(pidG)
        Me.objG.incluirEstudianteEquipo(pidEq, pidE)
    End Sub

    Public Sub escluirEstudianteEquipo(ByVal pidG As Integer, ByVal pidE As Integer)
        Me.obtenerGrupo(pidG)
        Me.objG.escluirEstudianteEquipo(pidE)
    End Sub

    Public Sub registrarEquipo(ByVal pidG As Integer, ByVal pnombre As String)
        Me.obtenerGrupo(pidG)
        Me.objG.registrarEquipo(pnombre)
    End Sub

    Public Sub modificarEquipo(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pnombre As String)
        Me.obtenerGrupo(pidG)
        Me.objG.modificarEquipo(pidE, pnombre)
    End Sub

    Public Sub eliminarEquipo(ByVal pidG As Integer, ByVal pidE As Integer)
        Me.obtenerGrupo(pidG)
        Me.objG.eliminarEquipo(pidE)
    End Sub

    Public Function darEstudiante(ByVal pidG As Integer, ByVal pidE As Integer) As DataTable
        Dim datos As New DataTable()
        Me.obtenerGrupo(pidG)
        datos = objG.darstudiante(pidE)
        Return datos
    End Function

    Public Function mostrarPromedioEquipo(ByVal pidG As Integer, ByVal pidE As Integer) As ArrayList
        Dim datos As New ArrayList()
        Me.obtenerGrupo(pidG)
        datos = objG.mostrarPromedioEquipo(pidE)
        Return datos
    End Function

    Public Function mostrarDesgloseEquipo(ByVal pidG As Integer, ByVal pidE As Integer) As DataTable
        Dim datos As New DataTable()
        Me.obtenerGrupo(pidG)
        datos = objG.mostrarDesgloseEquipo(pidE)
        Return datos
    End Function

    Public Sub modificarNotaGrupal(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pidR As Integer, ByVal pnota As String)
        Me.obtenerGrupo(pidG)
        objG.modificarNotaGrupal(pidE, pidR, pnota)
    End Sub

    Public Function obtenerNotasEstudiantes(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pidR As Integer) As DataTable
        Me.obtenerGrupo(pidG)
        Return Me.objG.obtenerNotasEstudiantes(pidE, pidR)
    End Function

    Public Function obtenerSumatoria(ByVal pidG As Integer, ByVal pidE As Integer, ByVal pidR As Integer) As String
        Me.obtenerGrupo(pidG)
        Return Me.objG.obtenerSumatoria(pidE, pidR)
    End Function

    Public Sub cerrarGrupoCuatrimestre(ByVal pidC As Integer, ByVal pidG As Integer)
        Me.obtenerGrupo(pidG)
        Dim objC As Curso
        objC = Me.obtenerCurso(pidC)
        Me.objG.cerrar()
        objC.copiese(pidG)
    End Sub

    Public Sub activarGrupo(ByVal pidC As Integer, ByVal pidG As Integer)
        Me.obtenerGrupo(pidG)
        Me.objG.activarse()
    End Sub
End Class
